﻿using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using YogaStudio.Data;
using YogaStudio.Data.Domain;

namespace YogaStudio.Service.BLL
{
   public class ScheduleService : IScheduleService
   {
        private YogaStudioEntities db;

        public ScheduleService()
       {
           db = new YogaStudioEntities();
       }
       public List<Schedule> GetAllSchedules()
       {
           return db.Schedules.ToList();
       }
       public Schedule GetSchedule(int id)
       {
           return db.Schedules.Find(id);

       }
       public bool DeleteSchedule(Schedule schedule)
       {
           if (schedule == db.Schedules.Remove(schedule))
           {
               db.SaveChanges();
           }
               return true;

       }
       public void UpdateSchedule(Schedule schedule)
       {
           db.Entry(schedule).State = EntityState.Modified;
          db.SaveChanges();
       }
       public void SaveSchedule(Schedule schedule)
       {
           db.Schedules.Add(schedule);
           db.SaveChanges();
       }
       public void Dispose(bool disposing)
       {
           db.Dispose();
         
       }
    }
}
